class Solution:
    def countBinarySubstrings(self, s: str) -> int:
        if len(s) == 0:
            return 0
        a = ''
        b = ''
        anum = 0
        bnum = 0
        r = 0
        for i in s:
            if i!=b:
                r += min(anum,bnum)
                a,anum = b,bnum
                b = i
                bnum = 1
            else:
                bnum += 1
        r += min(anum, bnum)
        return r

if __name__ == '__main__':
    so = Solution()
    num =  "00110011"
    r = so.countBinarySubstrings(num)
    print(r)
